package com.mujin.keji.collectionsystem.widget;

import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mujin.keji.collectionsystem.R;
import com.mujin.keji.collectionsystem.dialog.BaseNiceDialog;
import com.mujin.keji.collectionsystem.dialog.NiceDialog;
import com.mujin.keji.collectionsystem.dialog.ViewConvertListener;
import com.mujin.keji.collectionsystem.dialog.ViewHolder;

/**
 * 选择类型对话框
 *
 * @author weishixiong
 * @Time 2018-05-24
 */

public class SelectTypeDailog {
    private FragmentActivity context;
    private SelectTypeListener listener;

    public SelectTypeDailog(FragmentActivity context, SelectTypeListener listener) {
        this.context = context;
        this.listener = listener;

    }

    public interface SelectTypeListener {
        /**
         * 选择地址类型
         *
         * @param addressType
         */
        void selectAddress(String addressType);

        /**
         * 选择交通工具
         *
         * @param vehicle
         */
        void selectVehicle(String vehicle);

        /**
         * 选择外访情况
         *
         * @param visitSituation
         */
        void selectVehicleVisitSituation(String visitSituation);
    }

    /**
     * 选择地址类型对话框
     *
     * @param
     */
    public void showSelectAddressTypeDailog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dailog_selectaddresstype)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        final TextView tvOne = (TextView) holder.getView(R.id.tv_one);
                        final TextView tvTwo = (TextView) holder.getView(R.id.tv_two);
                        final TextView tvThree = (TextView) holder.getView(R.id.tv_three);
                        final TextView tvFour = (TextView) holder.getView(R.id.tv_four);
                        TextView tvCancel = (TextView) holder.getView(R.id.tv_cancel);
                        tvOne.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectAddress(tvOne.getText().toString());
                            }
                        });
                        tvTwo.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectAddress(tvTwo.getText().toString());
                            }
                        });
                        tvThree.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectAddress(tvThree.getText().toString());
                            }
                        });
                        tvFour.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectAddress(tvFour.getText().toString());
                            }
                        });
                        tvCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });


                    }
                }).
                setShowBottom(true)
                .show(context.getSupportFragmentManager());
    }

    /**
     * 选择交通工具
     *
     * @param
     */
    public void showSelectVehicleDailog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dailog_vehicle)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {
                        final TextView  tvOne = holder.getView(R.id.tv_one);
                        final TextView  tvTwo = holder.getView(R.id.tv_two);
                        final TextView tvThree =  holder.getView(R.id.tv_three);
                        final TextView tvFour =  holder.getView(R.id.tv_four);
                        TextView  tvCancel =  holder.getView(R.id.tv_cancel);
                        tvOne.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicle(tvOne.getText().toString());
                            }
                        });
                        tvTwo.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicle(tvTwo.getText().toString());
                            }
                        });
                        tvThree.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicle(tvThree.getText().toString());
                            }
                        });
                        tvFour.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicle(tvFour.getText().toString());
                            }
                        });
                        tvCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });
                    }
                }).
                setShowBottom(true)
                .show(context.getSupportFragmentManager());
    }

    /**
     * 选择外访情况
     *
     * @param
     */
    public void showSelectVisitSituationDailog() {
        NiceDialog.init()
                .setLayoutId(R.layout.dailog_visit_situation)
                .setConvertListener(new ViewConvertListener() {
                    @Override
                    public void convertView(ViewHolder holder, final BaseNiceDialog dialog) {

                        final TextView  tvOne = holder.getView(R.id.tv_one);
                        final TextView  tvTwo = holder.getView(R.id.tv_two);
                        final TextView tvThree =  holder.getView(R.id.tv_three);
                        final TextView tvFour =  holder.getView(R.id.tv_four);
                        final TextView  tvFive = holder.getView(R.id.tv_five);
                        final TextView  tvSix =  holder.getView(R.id.tv_six);
                        final TextView  tvSeven =  holder.getView(R.id.tv_seven);
                        final TextView  tvEight =  holder.getView(R.id.tv_eight);
                        TextView  tvCancel =  holder.getView(R.id.tv_cancel);
                        tvOne.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvOne.getText().toString());
                            }
                        });
                        tvTwo.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvTwo.getText().toString());
                            }
                        });
                        tvThree.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvThree.getText().toString());
                            }
                        });
                        tvFour.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvFour.getText().toString());
                            }
                        });



                        tvFive.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvFive.getText().toString());
                            }
                        });
                        tvSix.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvSix.getText().toString());
                            }
                        });
                        tvSeven.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvSeven.getText().toString());
                            }
                        });
                        tvEight.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                                listener.selectVehicleVisitSituation(tvEight.getText().toString());
                            }
                        });
                        tvCancel.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                dialog.dismiss();
                            }
                        });

                    }
                }).
                setShowBottom(true)
                .show(context.getSupportFragmentManager());
    }
}
